package com.whr.baseui.mvvm

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView

abstract class BaseBindingRvAdapter<T>(var data: MutableList<T> = mutableListOf()) :
    RecyclerView.Adapter<BaseBindingViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseBindingViewHolder {
        return BaseBindingViewHolder(
            DataBindingUtil.inflate(
                LayoutInflater.from(parent?.context),
                viewType,
                parent,
                false
            )
        )
    }

    override fun getItemCount(): Int {
        return data.size
    }

    fun addData(data:List<T>){
        this.data.addAll(data)
        this.notifyDataSetChanged()
    }


}